import json

import requests

from common.config import getconf, getToken, getToken_b


class Flow:
    def dashboard_humanFace(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/dashboard"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('摄像头看板', r.json())
        return r.json()

    def dashboard_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/dashboard"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外看板', r.json())
        return r.json()

    def terminalFlowRatio_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/terminalFlowRatio"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外看板', r.json())
        return r.json()

    def terminalFlowRatio_humanFace(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/terminalFlowRatio"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外看板', r.json())
        return r.json()

    def timeFlow_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/timeFlow"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外看板', r.json())
        return r.json()

    def timeFlow_humanFace(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/timeFlow"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外看板', r.json())
        return r.json()

    def jobTime_infrared(self,env):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/flow/jobTime"
        token = getToken(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        params1 = {"tag": 'infrared'}
        r = requests.get(url, headers=header,params=params1)
        #print('实时红外时间', r.json())
        return r.json()

    def jobTime_humanFace(self,env):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/flow/jobTime"
        token = getToken(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        params1 = {"tag": 'humanFace'}
        r = requests.get(url, headers=header,params=params1)
        #print('实时摄像头最大时间', r.json())
        return r.json()

    def tab(self,env):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/flow/tab"
        token = getToken(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        r = requests.get(url, headers=header)
        #print('标签', r.json())
        return r.json()

    def terminalFlowPage(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/terminalFlowPage"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"size":50,"current":1,"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('摄像头设备列表', r.json())
        return r.json()

    def terminalFlowPage_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/terminalFlowPage"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"size":50,"current":1,"startDt":startDt,"endDt":endDt}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外设备列表', r.json())
        return r.json()

    def terminalFlowDetail(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/terminalFlowDetail"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt,"terminalId":100183,"terminalAddress":"人脸识别测试点位谁动杀谁"}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('摄像头详情', r.json())
        return r.json()

    def terminalFlowDetail_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/terminalFlowDetail"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt,"terminalId":101146,"terminalAddress":"3288公司测式屏"}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外详情', r.json())
        return r.json()

    def terminalTimeFlow(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/humanFace/terminalTimeFlow"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt,"terminalId":100183,"terminalAddress":"人脸识别测试点位谁动杀谁"}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('摄像头设备趋势', r.json())
        return r.json()

    def terminalTimeFlow_infrared(self, env,startDt,endDt):
        base_url = getconf(env, "data_url")
        url = base_url + "triton/v1/infrared/terminalTimeFlow"
        token = getToken_b(env)
        header = {"Content-Type": "application/json;charset=UTF-8", "token": token}
        data = {"startDt":startDt,"endDt":endDt,"terminalId":101146,"terminalAddress":"3288公司测式屏"}
        r = requests.post(url, data=json.dumps(data), headers=header)
        #print('红外设备趋势', r.json())
        return r.json()





a=Flow()
#a.timeFlow_infrared('test','2020-09-03','2020-09-03')